#!/usr/bin/python2.5
#
import unittest
from google.appengine.api.users import User
from google.appengine.ext import webapp
from google.appengine.ext import db
import logging
import mm2notes_gae
import meeting
import schema
import os

class MeetingTest(unittest.TestCase):
    def setUp(self):
        self.application = webapp.WSGIApplication([('/', mm2notes_gae.Mm2Notes)], 
                                                  debug=True)
        
    def test_importcreation(self):
        logging.warning('Running import creation')
        user = User('test@example.com')
        fname = 'test/tests/simple.mm'
        dict_file = fname.replace('.mm', '_dict.py')
        meet = meeting.Meeting()
        text = file(fname).read()
        key = meet.add_meeting(user, fname, text)
        smeet = db.get(key)
        expected = eval(file(dict_file).read())
        self.assertEqual(expected['topic'][0], smeet.topic)
        self.assertEqual(text, smeet.mm_source)
        self.assertEquals(expected['attendees'], smeet.attendees)
        self.assertEquals(expected['emails'], smeet.emails)
        
        meet.delete_meeting(key)


